<template>
  <div class="EnterpriseRegister_bigbox">
    <div class="EnterpriseRegister_tishi_bigbox" v-if="ts">
      <div class="EnterpriseRegister_tishi_box">
        <div class="EnterpriseRegister_tishi_nextbox">
          <div class="EnterpriseRegister_tishi_nextbox_top">
            <div class="EnterpriseRegister_tishi_nextbox_title">
              您的企业信息已提交成功
            </div>
            <div class="EnterpriseRegister_tishi_nextbox_text">
              稍后我们的工作人员将与您取得联系
            </div>
          </div>
          <div class="EnterpriseRegister_tishi_nextbox_but">我知道了</div>
        </div>
        <div class="EnterpriseRegister_tishi_nextimg">
          <img src="../../assets/on.png" class="EnterpriseRegister_tishi_img" />
        </div>
      </div>
    </div>
    <div class="EnterpriseRegister_box">
      <div class="EnterpriseRegister_box_top">
        <div class="EnterpriseRegister_box_top_left">
          <div class="EnterpriseRegister_box_top_left_imgbox">
            <img
              src="../../assets/logo.png"
              class="EnterpriseRegister_box_top_left_img"
            />
          </div>
          <div class="EnterpriseRegister_box_top_left_text">
            贡聘招聘系统企业管理端
          </div>
        </div>
        <div class="EnterpriseRegister_box_top_right">
          <div class="EnterpriseRegister_box_top_right_box">
            <div class="EnterpriseRegister_box_top_right_box_num heightlin">
              1
            </div>
            <div
              class="EnterpriseRegister_box_top_right_box_text heightlintext"
            >
              微信授权注册
            </div>
          </div>
          <div
            class="EnterpriseRegister_box_top_right_heng heightlinheng"
          ></div>
          <div class="EnterpriseRegister_box_top_right_box">
            <div class="EnterpriseRegister_box_top_right_box_num heightlin">
              2
            </div>
            <div
              class="EnterpriseRegister_box_top_right_box_text heightlintext"
            >
              企业信息填写
            </div>
          </div>
          <div class="EnterpriseRegister_box_top_right_heng"></div>
          <div class="EnterpriseRegister_box_top_right_box">
            <div class="EnterpriseRegister_box_top_right_box_num">3</div>
            <div class="EnterpriseRegister_box_top_right_box_text">
              注册成功
            </div>
          </div>
        </div>
      </div>
      <div class="EnterpriseRegister_box_main">
        <el-form :model="from" :rules="rules" ref="ruleFormRef">
          <div class="EnterpriseRegister_box_main_one" v-if="indexOne">
            <div class="EnterpriseRegister_box_main_one_top">
              <div class="EnterpriseRegister_box_main_one_top_title">
                企业基础信息填写
              </div>
              <a
                class="EnterpriseRegister_box_main_one_top_text"
                href="https://rc.yping.net/bxcompany/login.php"
                >返回首页</a
              >
            </div>
            <div class="EnterpriseRegister_box_main_one_main">
              <div class="EnterpriseRegister_box_main_one_main_one">
                <div class="EnterpriseRegister_box_main_one_main_one_box">
                  <div
                    class="EnterpriseRegister_box_main_one_main_one_box_title"
                  >
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                    >
                      *
                    </div>
                    企业名称
                  </div>
                  <el-input
                    v-model="EnterpriseName"
                    class="EnterpriseRegister_box_main_one_main_one_input"
                    placeholder="请输入企业名称"
                  />
                </div>
                <div class="EnterpriseRegister_box_main_one_main_one_box">
                  <div
                    class="EnterpriseRegister_box_main_one_main_one_box_title"
                  >
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                    >
                      *
                    </div>
                    联系人
                  </div>
                  <el-input
                    v-model="contacts"
                    class="EnterpriseRegister_box_main_one_main_one_input"
                    placeholder="请输入联系人"
                  />
                </div>
              </div>
              <div class="EnterpriseRegister_box_main_one_main_two">
                <div class="EnterpriseRegister_box_main_one_main_one_box">
                  <div
                    class="EnterpriseRegister_box_main_one_main_one_box_title2"
                  >
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                    >
                      *
                    </div>
                    电话
                  </div>
                  <el-input
                    v-model="contactsphone"
                    class="EnterpriseRegister_box_main_one_main_one_input"
                    placeholder="请输入联系人电话"
                    @input="contactsphoneInput"
                  />
                </div>
                <div class="EnterpriseRegister_box_main_one_main_one_box">
                  <div
                    class="EnterpriseRegister_box_main_one_main_one_box_title"
                  >
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                    >
                      *
                    </div>
                    企业性质
                  </div>
                  <el-select
                    v-model="sysnature"
                    placeholder="请选择企业性质"
                    class="EnterpriseRegister_box_main_one_main_one_input"
                    clearable
                  >
                    <el-option
                      v-for="item in sysnatureData"
                      :key="item.id"
                      :label="item.title"
                      :value="item.id"
                    />
                  </el-select>
                </div>
              </div>
              <div class="EnterpriseRegister_box_main_one_main_three">
                <div class="EnterpriseRegister_box_main_one_main_three_left">
                  <div
                    class="EnterpriseRegister_box_main_one_main_three_left_left"
                  >
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title"
                    >
                      <div
                        class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                      >
                        *
                      </div>
                      营业执照
                    </div>
                    <div
                      class="EnterpriseRegister_box_main_one_main_three_left_left_right"
                    >
                      <el-upload
                        v-model:file-list="businesslicense"
                        :http-request="uploadSubmuit"
                        :auto-upload="false"
                        list-type="text"
                        :show-file-list="false"
                        :on-change="businesslicenseChange"
                        :on-exceed="businesslicenseExceed"
                        limit="1"
                        ref="businesslicenseRef"
                      >
                        <el-image
                          v-if="businesslicense.length > 0"
                          :src="businesslicense[0].url"
                          fit="cover"
                          class="EnterpriseRegister_box_main_one_main_three_left_left_right_img"
                        ></el-image>
                        <el-image
                          v-if="businesslicenseimg"
                          :src="businesslicenseimg"
                          fit="cover"
                          class="EnterpriseRegister_box_main_one_main_three_left_left_right_img"
                        ></el-image>
                        <el-icon
                          v-else
                          class="EnterpriseRegister_box_main_one_main_three_left_left_right_img2"
                          ><Plus
                        /></el-icon>
                      </el-upload>
                    </div>
                  </div>
                  <div
                    class="EnterpriseRegister_box_main_one_main_three_left_right"
                  >
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title"
                    >
                      <div
                        class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                      >
                        *
                      </div>
                      企业LOGO
                    </div>
                    <div
                      class="EnterpriseRegister_box_main_one_main_three_left_left_right"
                    >
                      <el-upload
                        v-model:file-list="logo"
                        :http-request="uploadSubmuit"
                        :auto-upload="false"
                        list-type="text"
                        :show-file-list="false"
                        :on-change="logoChange"
                        :on-exceed="logoExceed"
                        limit="1"
                        ref="logoRef"
                      >
                        <el-image
                          v-if="logo.length > 0"
                          :src="logo[0].url"
                          fit="cover"
                          class="EnterpriseRegister_box_main_one_main_three_left_left_right_img"
                        ></el-image>
                        <el-image
                          v-if="logoimg"
                          :src="logoimg"
                          fit="cover"
                          class="EnterpriseRegister_box_main_one_main_three_left_left_right_img"
                        ></el-image>
                        <el-icon
                          v-else
                          class="EnterpriseRegister_box_main_one_main_three_left_left_right_img2"
                          ><Plus
                        /></el-icon>
                      </el-upload>
                    </div>
                  </div>
                </div>
                <div class="EnterpriseRegister_box_main_one_main_three_right">
                  <div>
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title"
                    >
                      <div
                        class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                      >
                        *
                      </div>
                      在职证明
                    </div>
                    <a
                      :href="wb"
                      class="EnterpriseRegister_box_main_one_main_one_box_title_a"
                    >
                      下载范本
                    </a>
                  </div>
                  <div
                    class="EnterpriseRegister_box_main_one_main_three_left_left_right"
                  >
                    <el-upload
                      v-model:file-list="proveimg"
                      :http-request="uploadSubmuit"
                      :auto-upload="false"
                      list-type="text"
                      :show-file-list="false"
                      :on-change="proveimgChange"
                      :on-exceed="proveimgExceed"
                      limit="1"
                      ref="proveimgRef"
                    >
                      <el-image
                        v-if="proveimg.length > 0"
                        :src="proveimg[0].url"
                        fit="cover"
                        class="EnterpriseRegister_box_main_one_main_three_left_left_right_img"
                      ></el-image>
                      <el-image
                        v-if="proveImg"
                        :src="proveImg"
                        fit="cover"
                        class="EnterpriseRegister_box_main_one_main_three_left_left_right_img"
                      ></el-image>
                      <el-icon
                        v-else
                        class="EnterpriseRegister_box_main_one_main_three_left_left_right_img2"
                        ><Plus
                      /></el-icon>
                    </el-upload>
                  </div>
                </div>
              </div>
              <div class="EnterpriseRegister_box_main_one_main_two">
                <div
                  class="EnterpriseRegister_box_main_one_main_three_left_left"
                >
                  <div
                    class="EnterpriseRegister_box_main_one_main_one_box_title"
                  >
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                    >
                      *
                    </div>
                    企业行业
                  </div>
                  <el-cascader
                    v-model="industryOptions"
                    :options="industryData"
                    :props="industryProps"
                    @change="industryChange"
                    placeholder="请选择企业行业"
                    clearable
                    style="height: 45px"
                    class="EnterpriseRegister_box_main_one_main_one_input"
                  >
                    <template #default="{ node, data }">
                      <span>{{ data.name }}</span>
                      <span v-if="!node.isLeaf">
                        ({{ data.children.length }})
                      </span>
                    </template>
                  </el-cascader>
                </div>
                <div class="EnterpriseRegister_box_main_one_main_one_box">
                  <div
                    class="EnterpriseRegister_box_main_one_main_one_box_title"
                  >
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                    >
                      *
                    </div>
                    企业规模
                  </div>
                  <el-select
                    v-model="syssize"
                    placeholder="请选择企业规模"
                    class="EnterpriseRegister_box_main_one_main_one_input"
                    clearable
                  >
                    <el-option
                      v-for="item in syssizeData"
                      :key="item.id"
                      :label="item.title"
                      :value="item.id"
                    />
                  </el-select>
                </div>
              </div>
              <div class="EnterpriseRegister_box_main_one_main_two">
                <div
                  class="EnterpriseRegister_box_main_one_main_three_left_left"
                >
                  <div
                    class="EnterpriseRegister_box_main_one_main_one_box_title"
                  >
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                    >
                      *
                    </div>
                    企业区域
                  </div>
                  <el-cascader
                    v-model="areaOptions"
                    :options="areaData"
                    :props="areaProps"
                    @change="areaChange"
                    placeholder="请选择板块"
                    clearable
                    style="height: 45px"
                    class="EnterpriseRegister_box_main_one_main_one_input"
                  >
                    <template #default="{ node, data }">
                      <span>{{ data.name }}</span>
                      <span v-if="!node.isLeaf">
                        ({{ data.children.length }})
                      </span>
                    </template>
                  </el-cascader>
                </div>
                <div class="EnterpriseRegister_box_main_one_main_one_box">
                  <div
                    class="EnterpriseRegister_box_main_one_main_one_box_title"
                  >
                    <div
                      class="EnterpriseRegister_box_main_one_main_one_box_title_b"
                    >
                      *
                    </div>
                    企业地址
                  </div>
                  <el-input
                    v-model="site"
                    class="EnterpriseRegister_box_main_one_main_one_input"
                    placeholder="请输入企业地址"
                  />
                </div>
              </div>
            </div>
            <div class="EnterpriseRegister_box_main_one_main_bom">
              <div
                class="EnterpriseRegister_box_main_one_main_bom_but"
                @click="indexOneClick"
              >
                下一步
              </div>
            </div>
          </div>
          <div class="EnterpriseRegister_box_main_two" v-else-if="indexTwo">
            <div class="EnterpriseRegister_box_main_one_top">
              <div class="EnterpriseRegister_box_main_one_top_title">
                填写企业基础信息
              </div>
              <a
                href="https://rc.yping.net/bxcompany/login.php"
                class="EnterpriseRegister_box_main_one_top_text"
                >返回首页</a
              >
            </div>
            <div class="EnterpriseRegister_box_main_two_main">
              <el-scrollbar height="458px">
                <div class="EnterpriseRegister_box_main_two_main_one">
                  <el-input
                    v-model="describe"
                    type="textarea"
                    class="EnterpriseRegister_box_main_two_main_one_input"
                    placeholder="请输入企业描述"
                  />
                </div>
                <div class="EnterpriseRegister_box_main_two_main_two">
                  <div class="EnterpriseRegister_box_main_two_main_two_top">
                    <div class="EnterpriseRegister_box_main_two_main_two_title">
                      企业福利
                    </div>
                    <div class="EnterpriseRegister_box_main_two_main_two_text">
                      (可多选)
                    </div>
                  </div>
                  <div class="EnterpriseRegister_box_main_two_main_two_bom">
                    <div
                      class="EnterpriseRegister_box_main_two_main_two_bom_but"
                      v-for="(item, index) in syswelfareData"
                      :key="index"
                      :class="syswelfare.includes(item.id) ? 'heightbut' : ''"
                      @click="syswelfareFun(item.id)"
                    >
                      {{ item.title }}
                    </div>
                  </div>
                </div>
                <div class="EnterpriseRegister_box_main_two_main_three">
                  <div class="EnterpriseRegister_box_main_two_main_two_top">
                    <div class="EnterpriseRegister_box_main_two_main_two_title">
                      热门商圈
                    </div>
                    <div class="EnterpriseRegister_box_main_two_main_two_text">
                      (可多选)
                    </div>
                  </div>
                  <div class="EnterpriseRegister_box_main_two_main_two_bom">
                    <div
                      class="EnterpriseRegister_box_main_two_main_two_bom_but"
                      v-for="(item, index) in sysareacircleData"
                      :key="index"
                      :class="
                        sysareacircle.includes(item.id) ? 'heightbut' : ''
                      "
                      @click="sysareacircleFun(item.id)"
                    >
                      {{ item.title }}
                    </div>
                  </div>
                </div>
              </el-scrollbar>
            </div>
            <div class="EnterpriseRegister_box_main_one_main_bom">
              <div
                class="EnterpriseRegister_box_main_one_main_bom_left"
                @click="indexThreeClick"
              >
                返回上一步
              </div>
              <div
                class="EnterpriseRegister_box_main_one_main_bom_but"
                @click="indexTwoClick"
              >
                下一步
              </div>
            </div>
          </div>
          <div class="EnterpriseRegister_box_main_three" v-else-if="indexThree">
            <div class="EnterpriseRegister_box_main_one_top">
              <div class="EnterpriseRegister_box_main_one_top_title">
                上传企业办公环境
                <div class="EnterpriseRegister_box_main_one_top_title_text">
                  （最多可上传9张图片）
                </div>
              </div>
              <a
                href="https://rc.yping.net/bxcompany/login.php"
                class="EnterpriseRegister_box_main_one_top_text"
                >返回首页</a
              >
            </div>
            <div class="EnterpriseRegister_box_main_three_main">
              <el-scrollbar height="458px">
                <div class="EnterpriseRegister_box_main_three_main_box">
                  <div
                    class="EnterpriseRegister_box_main_three_main_box_imgbox"
                    v-for="(item, index) in setcompanyimg"
                    :key="index"
                  >
                    <el-image
                      :src="item.url ? item.url : item.img"
                      fit="cover"
                      class="EnterpriseRegister_box_main_three_main_box_img"
                    ></el-image>
                  </div>
                  <div
                    class="EnterpriseRegister_box_main_three_main_box_upload_box"
                  >
                    <el-upload
                      v-model:file-list="setcompanyimg"
                      :http-request="uploadSubmuit"
                      :auto-upload="false"
                      list-type="text"
                      :show-file-list="false"
                      :on-change="setcompanyimgChange"
                      :on-exceed="setcompanyimgExceed"
                      multiple="true"
                      limit="9"
                      ref="setcompanyimgRef"
                    >
                      <div
                        class="EnterpriseRegister_box_main_three_main_box_icon_box"
                      >
                        <el-icon
                          class="EnterpriseRegister_box_main_three_main_box_icon"
                          ><Plus
                        /></el-icon>
                        <div
                          class="EnterpriseRegister_box_main_three_main_box_icon_text"
                        >
                          2mb以内照片
                        </div>
                      </div>
                    </el-upload>
                  </div>
                </div>
              </el-scrollbar>
            </div>
            <div class="EnterpriseRegister_box_main_one_main_bom">
              <div
                class="EnterpriseRegister_box_main_one_main_bom_left"
                @click="indexFourClick"
              >
                返回上一步
              </div>
              <div
                class="EnterpriseRegister_box_main_one_main_bom_but"
                @click="SaveFun"
              >
                提交注册
              </div>
            </div>
          </div>
        </el-form>
      </div>
      <div class="EnterpriseRegister_box_bom">
        Copyright C 2015-2023 All Rights Reserved 版权所有 贡聘 蜀ICP备1222
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, getCurrentInstance, reactive } from "vue";
import { ElMessage, ElMessageBox, genFileId } from "element-plus";
import BaseUrl from "../../../test";
const { proxy } = getCurrentInstance();
//**************************************数据定义**************************************
//获取openid
const appopenid = ref(sessionStorage.getItem("data"));
//表单验证属性定义
//企业名称
const EnterpriseName = ref();
//联系人
const contacts = ref();
//电话
const contactsphone = ref();
//企业性质
const sysnature = ref();
const sysnatureData = ref();
//营业执照
const businesslicense = ref([]);
const businesslicenseimg = ref();
const businesslicenseRef = ref();
//企业Logo
const logo = ref([]);
const logoimg = ref();
const logoRef = ref([]);
//在职证明
const proveimg = ref([]);
const proveImg = ref([]);
const proveimgRef = ref([]);
//企业行业数据
const industryData = ref([]);
const industryOptions = ref([]);
const industryID = ref([]);
const industryProps = {
  value: "id",
  label: "name",
  topid: "topid",
  children: "children",
};
//企业规模
const syssize = ref();
const syssizeData = ref();
//企业区域
const areaData = ref([]);
const areaOptions = ref([]);
const areaID = ref([]);
const areaProps = {
  value: "id",
  label: "name",
  topid: "topid",
  children: "children",
};
//企业地址
const site = ref();
//企业简介
const describe = ref();
//企业福利
const syswelfareData = ref();
const syswelfare = ref([]);
//热门商圈
const sysareacircleData = ref();
const sysareacircle = ref([]);
//图片列表
const setcompanyimg = ref([]);
const setcompanyimgRef = ref([]);
//页面切换
const indexOne = ref(true);
const indexTwo = ref(false);
const indexThree = ref(false);
//文本下载
const wb = ref();
//提示判断
const ts = ref(false);
//**************************************方法定义**************************************
//页面切换
const indexOneClick = () => {
  indexOne.value = false;
  indexTwo.value = true;
};
const indexTwoClick = () => {
  indexTwo.value = false;
  indexThree.value = true;
};
const indexThreeClick = () => {
  indexOne.value = true;
  indexTwo.value = false;
};
const indexFourClick = () => {
  indexTwo.value = true;
  indexThree.value = false;
};
//电话验证
const contactsphoneInput = (event) => {
  const inputValue = event;
  const newValue = inputValue.replace(/[^\d]/g, "");
  contactsphone.value = newValue;
};
//选择器方法
const formatData = (data) => {
  return data.map((item) => ({
    id: item.id,
    name: item.title,
    topid: item.topid,
    children: item.sub ? formatData(item.sub) : [], // 如果有子选项，递归格式化
  }));
};
const formatData2 = (data) => {
  return data.map((item) => ({
    id: item.id,
    name: item.title,
    topid: item.topid,
    children: item.city
      ? item.city.map((city) => ({
          id: city.id,
          name: city.title,
          topid: city.topid,
          // 处理 area 层级
          children: city.area ? formatData2(city.area) : [], // 递归处理 area
        }))
      : [], // 如果有子选项，递归格式化
  }));
};
//营业执照覆盖上传
const businesslicenseExceed = (files) => {
  businesslicenseRef.value.clearFiles();
  const file = files[0];
  // file.uid = genFileId();
  businesslicenseRef.value.handleStart(file);
  console.log(businesslicense.value);
};
//营业执照图片获取base64方法
const businesslicenseChange = (file, files) => {
  files.forEach((item) => {
    const reader = new FileReader();
    reader.onload = (e) => {
      item.url = URL.createObjectURL(item.raw);
      file.base64 = e.target.result;
    };
    reader.readAsDataURL(item.raw);
  });
};
//企业LoGo覆盖上传
const logoExceed = (files) => {
  logoRef.value.clearFiles();
  const file = files[0];
  // file.uid = genFileId();
  logoRef.value.handleStart(file);
};
//企业LoGo图片获取base64方法
const logoChange = (file, files) => {
  files.forEach((item) => {
    const reader = new FileReader();
    reader.onload = (e) => {
      item.url = URL.createObjectURL(item.raw);
      file.base64 = e.target.result;
    };
    reader.readAsDataURL(item.raw);
  });
};
//在职证明覆盖上传
const proveimgExceed = (files) => {
  proveimgRef.value.clearFiles();
  const file = files[0];
  // file.uid = genFileId();
  proveimgRef.value.handleStart(file);
};
//在职证明图片获取base64方法
const proveimgChange = (file, files) => {
  files.forEach((item) => {
    const reader = new FileReader();
    reader.onload = (e) => {
      item.url = URL.createObjectURL(item.raw);
      file.base64 = e.target.result;
    };
    reader.readAsDataURL(item.raw);
  });
};
//企业办公环境覆盖上传
const setcompanyimgExceed = (files) => {
  setcompanyimgRef.value.clearFiles();
  const file = files[0];
  // file.uid = genFileId();
  setcompanyimgRef.value.handleStart(file);
};
//企业办公环境图片获取base64方法
const setcompanyimgChange = (file, files) => {
  files.forEach((item) => {
    const reader = new FileReader();
    reader.onload = (e) => {
      item.url = URL.createObjectURL(item.raw);
      file.base64 = e.target.result;
    };
    reader.readAsDataURL(item.raw);
  });
};
//企业行业筛选方法
const industryChange = (value) => {
  const result = {};
  // 遍历选中的值并生成新的键名
  value.forEach((item, index) => {
    const newKey = `key${index + 1}`; // 生成新键名
    result[newKey] = item; // 赋值
  });
  industryID.value = result;
};
//企业地区筛选方法
const areaChange = (value) => {
  const result = {};
  // 遍历选中的值并生成新的键名
  value.forEach((item, index) => {
    const newKey = `key${index + 1}`; // 生成新键名
    result[newKey] = item; // 赋值
  });
  areaID.value = result;
};
//企业福利选择方法
const syswelfareFun = (id) => {
  const index = syswelfare.value.indexOf(id);
  if (index > -1) {
    // 如果ID已存在，则移除
    syswelfare.value.splice(index, 1);
  } else {
    // 如果ID不存在，则添加
    syswelfare.value.push(id);
  }
};
//热门商圈
const sysareacircleFun = (id) => {
  const index = sysareacircle.value.indexOf(id);
  if (index > -1) {
    // 如果ID已存在，则移除
    sysareacircle.value.splice(index, 1);
  } else {
    // 如果ID不存在，则添加
    sysareacircle.value.push(id);
  }
};
//获取企业行业
const getsysindustry = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getsysindustry/",
      data: {
        topid: 0,
        type: 2,
        isall: 1,
      },
    })
    .then((res) => {
      if (res.data.code == 0) {
        const data = res.data.data;
        const formattedData = formatData(data);
        industryData.value = formattedData;
      }
    });
};
//获取企业区域
const getsysarea = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getsysarea/",
      data: {
        topid: 0,
        type: 2,
        isall: 1,
      },
    })
    .then((res) => {
      if (res.data.code == 0) {
        const data = res.data.data;
        const formattedData = formatData2(data);
        areaData.value = formattedData;
      }
    });
};
//获取企业福利
const getsyswelfare = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getsyswelfare/",
    })
    .then((res) => {
      if (res.data.code == 0) {
        syswelfareData.value = res.data.data;
      }
    });
};
//获取热门商圈
const getsysareacircle = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getsysareacircle/",
    })
    .then((res) => {
      if (res.data.code == 0) {
        sysareacircleData.value = res.data.data;
      }
    });
};
//获取企业性质
const getsysnature = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getsysnature/",
    })
    .then((res) => {
      if (res.data.code == 0) {
        sysnatureData.value = res.data.data;
      }
    });
};
//获取企业规模
const getsyssize = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getsyssize/",
    })
    .then((res) => {
      if (res.data.code == 0) {
        syssizeData.value = res.data.data;
      }
    });
};
//获取范本
const getExtraSaveParam = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getExtraSaveParam/",
      data: {
        val: "sharetempfiledoc",
      },
    })
    .then((res) => {
      if (res.data.code == 0) {
        wb.value = res.data.web + res.data.data;
      }
    });
};
//保存方法
const SaveFun = () => {
  if (!EnterpriseName.value) {
    ElMessage.error("您的企业名称未填写！请填写！");
    return;
  }
  if (!contacts.value) {
    ElMessage.error("您的联系人未填写！请填写！");
    return;
  }
  if (!contactsphone.value) {
    ElMessage.error("您的联系人电话未填写！请填写！");
    return;
  }
  if (!sysnature.value) {
    ElMessage.error("您的企业性质未选择！请选择！");
    return;
  }
  if (businesslicense.value.length == 0) {
    ElMessage.error("您的营业执照未选择！请选择！");
    return;
  }
  if (logo.value.length == 0) {
    ElMessage.error("您的Logo未选择！请选择！");
    return;
  }
  if (proveimg.value.length == 0) {
    ElMessage.error("您的在职证明未选择！请选择！");
    return;
  }
  if (industryOptions.value.length == 0) {
    ElMessage.error("您的企业行业未选择！请选择！");
    return;
  }
  if (!syssize.value) {
    ElMessage.error("您的企业性质未选择！请选择！");
    return;
  }
  if (areaOptions.value.length == 0) {
    ElMessage.error("您的企业区域未选择！请选择！");
    return;
  }
  if (!site.value) {
    ElMessage.error("您的企业地址未填写！请填写！");
    return;
  }
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/setcompanyinfo/",
      data: {
        appopenid: appopenid.value,
        name: EnterpriseName.value,
        contacts: contacts.value,
        contactsphone: contactsphone.value,
        sysnature: sysnature.value,
        industry: JSON.stringify(industryID.value),
        scale: syssize.value,
        area: JSON.stringify(areaID.value),
        site: site.value,
        describe: describe.value,
        welfare: JSON.stringify(syswelfare.value),
        areacircle: JSON.stringify(sysareacircle.value),
        lng: 0,
        lat: 0,
      },
    })
    .then((res) => {
      if (res.data.code == 0) {
        proxy.$Axios({
          method: "post",
          url: BaseUrl + "/wx.php/setcompanyinfoimgB64/",
          data: {
            id: res.data.data,
            appopenid: appopenid.value,
            type: "businesslicense",
            img: businesslicense.value[0].base64,
          },
        });
        proxy.$Axios({
          method: "post",
          url: BaseUrl + "/wx.php/setcompanyinfoimgB64/",
          data: {
            id: res.data.data,
            appopenid: appopenid.value,
            type: "logo",
            img: logo.value[0].base64,
          },
        });
        proxy.$Axios({
          method: "post",
          url: BaseUrl + "/wx.php/setcompanyinfoimgB64/",
          data: {
            id: res.data.data,
            appopenid: appopenid.value,
            type: "proveimg",
            img: proveimg.value[0].base64,
          },
        });
        for (let i = 0; i < setcompanyimg.value.length; i++) {
          proxy.$Axios({
            method: "post",
            url: BaseUrl + "/wx.php/setcompanyimgB64/",
            data: {
              company: res.data.data,
              appopenid: appopenid.value,
              type: 1,
              img: setcompanyimg.value[i].base64,
            },
          });
        }
        setTimeout(() => {
          ts.value = true;
        }, 2000);
      }
    });
};
//获取数据
const getcompanyinfobymember = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getcompanyinfobymember/",
      data: {
        appopenid: appopenid.value,
      },
    })
    .then((res) => {
      if (res.data.code == 0) {
        EnterpriseName.value = res.data.data.name;
        contacts.value = res.data.data.contacts;
        contactsphone.value = res.data.data.contactsphone;
        sysnature.value = res.data.data.nature;
        const industry = [
          res.data.data.industry1,
          res.data.data.industry2,
          res.data.data.industry3,
        ];
        industryOptions.value = industry;
        console.log(industryOptions.value);
        syssize.value = res.data.data.scale;
        areaOptions.value = res.data.data.area1;
        site.value = res.data.data.site;
        businesslicenseimg.value = res.data.data.businesslicense;
        proveImg.value = res.data.data.proveimg;
        logoimg.value = res.data.data.logo;
        describe.value = res.data.data.describe;
        syswelfare.value = res.data.data.welfare;
        sysareacircle.value = res.data.data.areacircle;
        setcompanyimg.value = res.data.data.imglist;
      }
    });
};
//**************************************运行**************************************
getsysindustry();
getsysarea();
getsyswelfare();
getsysareacircle();
getsysnature();
getsyssize();
getExtraSaveParam();
getcompanyinfobymember();
</script>

<style>
@import url("./EnterpriseRegister.css");
</style>
